package com.fgr.service.Impl;

import com.fgr.beans.Adapter;
import com.fgr.beans.Animal;
import com.fgr.mapper.AnimalMapper;
import com.fgr.service.AnimalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AnimalServiceImpl implements AnimalService {
    @Autowired
    AnimalMapper animalMapper;
    @Override
    public List<Animal> selectAllAnimal() {
        List<Animal> animals = animalMapper.selectAllAnimal();
        return animals;
    }

    @Override
    public List<Animal> selectAnimalByTypeId(Integer type_id) {
        List<Animal> animals = animalMapper.selectAnimalByTypeId(type_id);
        return animals;
    }

    @Override
    public List<Animal> selectAnimalByTypeIdAndStat(Integer type_id, Integer anStat) {
        List<Animal> animals = animalMapper.selectAnimalByTypeIdAndStat(type_id, anStat);
        return animals;
    }


    @Override
    public Animal selectAnimalById(Integer id) {
        Animal animal = animalMapper.selectAnimalById(id);
        return animal;
    }

    @Override
    public String insertAdapter(Animal animal) {
        Integer integer = animalMapper.insertAdapter(animal);
        if (integer>0){
            return "SUCCESS";
        }else{
            return "ERRO";
        }
    }

    @Override
    public String updateAnimalStat(Integer anId) {
        Integer integer = animalMapper.updateAnimalStat(anId);
        if (integer>0){
            return "SUCCESS";
        }else{
            return "ERRO";
        }
    }

    @Override
    public String updateAnimal(Animal animal) {
        Integer integer = animalMapper.updateAnimal(animal);
        if (integer>0){
            return "SUCCESS";
        }else{
            return "ERRO";
        }
    }

    @Override
    public String deleteAdapter(Integer an_id) {
        Integer integer = animalMapper.deleteAdapter(an_id);
        if (integer>0){
            return "SUCCESS";
        }else{
            return "ERRO";
        }
    }

    @Override
    public String deleteAnimalByTypeId(Integer type_id) {
        Integer integer = animalMapper.deleteAnimalByTypeId(type_id);
        if (integer>0){
            return "SUCCESS";
        }else{
            return "ERRO";
        }
    }


}
